package com.onlineMIS.ORM.DAO.headQ.qxbabydb;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.onlineMIS.ORM.DAO.headQ.barCodeGentor.ProductBarcodeDaoImpl;
import com.onlineMIS.ORM.entity.headQ.barcodeGentor.ProductBarcode;

import com.onlineMIS.ORM.entity.headQ.qxbabydb.ImgDetailsVO;
import com.onlineMIS.ORM.entity.headQ.qxbabydb.ProductBarcode2;
import com.onlineMIS.ORM.entity.headQ.qxbabydb.ProductBarcodePic2;

@Service
public class ProductBarcodePicService {

	@Autowired
	private ProductBarcodePicDaoImpl2 picDaoImpl;
	
	@Autowired
	private ProductBarcodeDaoImpl productBarcodeDaoImpl;
	
	
	public ImgDetailsVO getImgPath(String barcode) {
		ImgDetailsVO vo = new ImgDetailsVO();
		if (barcode != null && barcode != "") {
			//判断是否合法条码，数据库是否存在
			ProductBarcode productBarcode = productBarcodeDaoImpl.getByBarcode(barcode);
			if (productBarcode != null) {
				String pmUrlPath = picDaoImpl.getURLPathByBarcode(barcode, ProductBarcodePic2.TYPE_PING_MIAN_PIC);
				String phoneUrlPath = picDaoImpl.getURLPathByBarcode(barcode, ProductBarcodePic2.TYPE_SHOU_JI_PIC);
				vo.setPmUrlPath(pmUrlPath);
				vo.setPhoneUrlPath(phoneUrlPath);
				vo.setBarcode(productBarcode.getBarcode());
				vo.setProductCode(productBarcode.getProduct().getProductCode());
				
				if (productBarcode.getColor() != null)
					vo.setColor(productBarcode.getColor().getName());
				
				vo.setSize(productBarcode.getProduct().getSizeMin()+"-"+productBarcode.getProduct().getSizeMax());
				vo.setBrand(productBarcode.getProduct().getBrand().getBrand_Name());
				vo.setSalesPrice(productBarcode.getProduct().getSalesPrice());
//				int inventoryNum = headQInventoryStockDAOImpl.getInventory(productBarcode.getId());
//				vo.setInventoryNum(inventoryNum);
			}
		}
		return vo;
	}
	

}
